"""
题目：移除双链表的第一个节点，返回新的头节点（空链表返回 None）。
"""


class Node:
    def __init__(self, val=0, prev=None, next=None):
        self.val = val
        self.prev = prev
        self.next = next


def delete_head(head):
    """删除双链表的头节点"""
    if head is None:
        return None  # 空链表直接返回
    if head.next is None:
        return None  # 单节点链表，删除后为空
    # 新头节点是原头节点的后继
    new_head = head.next
    # 新头节点的前驱置空（断开与原头节点的联系） 不然显得不干净、不专业
    new_head.prev = None
    return new_head


def create_doubly_linked_list(arr):
    if not arr:
        return None
    head = Node(arr[0])
    current = head
    for val in arr[1:]:
        new_node = Node(val)
        current.next = new_node
        new_node.prev = current
        current = new_node
    return head


def traverse(head):
    result = []
    current = head
    while current:
        result.append(current.val)
        current = current.next
    return result


# 测试
if __name__ == "__main__":
    head = create_doubly_linked_list([1, 2, 3])
    new_head = delete_head(head)
    print(traverse(new_head))  # 输出: [2, 3]

    single_head = create_doubly_linked_list([5])
    new_single_head = delete_head(single_head)
    print(traverse(new_single_head))  # 输出: []